package com.leyou.item.clients;

import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author GL160601@163.com
 * @date 2020/12/12 20:16
 */
@FeignClient("item-service")
public interface ItemClient {

    /**
     * 分页查询spu
     *
     * @param page       当前页码
     * @param rows       每页显示记录数
     * @param brandId    品牌id
     * @param categoryId 商品分类id
     * @param id         spu的id
     * @param saleable   是否上架
     */
    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> queryPage(
            @RequestParam(value = "page", defaultValue = "1") Integer page,
            @RequestParam(value = "rows", defaultValue = "5") Integer rows,
            @RequestParam(value = "brandId", required = false) Long brandId,
            @RequestParam(value = "categoryId", required = false) Long categoryId,
            @RequestParam(value = "id", required = false) Long id,
            @RequestParam(value = "saleable", required = false) Boolean saleable);


    /**
     * 根据spuId查询sku集合
     *
     * @param cid
     * @return
     */
    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> querySkuListBySpuId(@RequestParam("id") Long cid);


    /**
     * 根据商品id（spuId）查询对应的规格参数组集合以及组内参数的信息，及对应值
     *
     * @param id
     * @param searching
     * @return
     */
    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> listSpec(
            @RequestParam("id") Long id,
            @RequestParam(value = "searching", required = false) Boolean searching);


    /**
     * 根据品牌id集合查询品牌集合
     *
     * @param ids
     * @return
     */
    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandByIds(@RequestParam("ids") List<Long> ids);


    /**
     * 根据id集合查询分类
     *
     * @param ids
     * @return
     */
    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIds(@RequestParam("ids") List<Long> ids);


    /**
     * 根据id查询商品
     *
     * @param cid
     * @return
     */
    @GetMapping("/goods/spu/{id}")
    SpuDTO querySpuById(@PathVariable("id") Long cid);


    /**
     * 根据id查询商品详情
     *
     * @param cid
     * @return
     */
    @GetMapping("/goods/spu/detail")
    SpuDetailDTO queryDetailById(@RequestParam("id") Long cid);

    /**
     * 根据id查询品牌
     *
     * @param id
     * @return
     */
    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id") Long id);

    @GetMapping("/spec/list")
    List<SpecGroupDTO> listSpecGroup(@RequestParam("id") Long id);

}

